/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.editparts;

import java.beans.PropertyChangeEvent;

import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.editpolicies.DirectEditPolicy;

import edu.pku.sei.modeler.figures.MetaPackageFigure;
import edu.pku.sei.modeler.images.ImageProvider;
import edu.pku.sei.modeler.model.core.MetaPackage;
import edu.pku.sei.modeler.model.structure.MetaShapeElement;
import edu.pku.sei.modeler.util.ResourceFactory;

/**
 * @author zl
 *
 */
public class MetaPackageEditPart extends MetaNamedElementEditPart {

	public MetaPackageEditPart (MetaShapeElement model) {
		super(model);
	}
	
	protected IFigure createFigure() {
		MetaPackageFigure fig = new MetaPackageFigure();
		fig.getNameLabel().setIcon(ImageProvider.getImage(ImageProvider.FIELD_PACKAGE_IMAGE));
		fig.getNameLabel().setFont(ResourceFactory.getHeadFont());
		return fig;
	}
	
	protected void createEditPolicies() {
		super.createEditPolicies();
		
	}
	
	protected MetaPackage getUMLModel() {
		return (MetaPackage)((MetaShapeElement)getModel()).getModelElement();
	}
	
	/* (non-Javadoc)
	 * @see edu.pku.modeler.control.editparts.BaseEditPart#createDirectEditPolicy()
	 */
	protected DirectEditPolicy createDirectEditPolicy() {
		return super.createDirectEditPolicy();
	}

	protected void handlePropertyChanged(PropertyChangeEvent event) {
		super.handlePropertyChanged(event);
	}
	
	protected void refreshVisuals() {
		super.refreshVisuals();
		MetaPackageFigure fig = (MetaPackageFigure)getFigure();
		fig.getNameLabel().setText(getUMLModel().getName());
	}
}
